package xyz.ddlnt.servicemq.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import xyz.ddlnt.commonutil.constant.MqConstants;

import xyz.ddlnt.model.entity.PostComment;
import xyz.ddlnt.servicemq.mapper.PostCommentMapper;
import xyz.ddlnt.servicemq.service.PostCommentService;

/**
 * @author ZZULI_SE 210910
 * @data 2025/5/28 2:59
 */
@Service
public class PostCommentServiceImpl extends ServiceImpl<PostCommentMapper, PostComment> implements PostCommentService {
    @Resource
    private PostCommentMapper postCommentMapper;

    @Override
    public void commentCountPlusOne(Long id) {
        LambdaUpdateWrapper<PostComment> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.setIncrBy(PostComment::getCommentCount, MqConstants.PLUS_ONE)
                .eq(PostComment::getId, id);
        postCommentMapper.update(updateWrapper);
    }
}
